<template>
  <transition name="ci">
    <div v-bind:class="['am-modal']">
      <div v-bind:class="'am-modal-dialog'">
        <slot></slot>
      </div>

      <div v-bind:class="'am-dimmer'" v-on:click="modalOnClick"></div>
    </div>
  </transition>
</template>

<script>
export default {
  name: 'am-modal',

  props: {
    size: String,

    isCloseViaDimmer: {     // 是否通过点击遮罩层关闭模态框，默认为true
      type: Boolean,
      default: true
    }
  },

  methods: {
    modalOnClick () {
      if (this.isCloseViaDimmer) {
        this.$emit('close', 'dimmer')
      }
    }
  }
}
</script>
